package com.wang.example.consumer;

import com.wang.example.common.model.User;
import com.wang.example.common.service.UserService;
import com.wang.wangrpc.bootstrap.ConsumerBootstrap;
import com.wang.wangrpc.proxy.ServiceProxyFactory;

/**
 * @Author 王子旭
 * @Date 2025/04/03 14:02
 * @Version 1.0
 */
public class ConsumerExample {
    public static void main(String[] args) throws InterruptedException {
        // 服务提供者初始化
        ConsumerBootstrap.init();

        UserService userService = ServiceProxyFactory.getProxy(UserService.class);
        for (int i = 0; ; i++) {
            User user = new User();
            user.setName("name_" + i);
            user = userService.getUser(user);
            System.out.printf("第%d次: ", i);
            if (user != null) {
                System.out.println(user.getName());
            } else {
                System.out.println("user == null");
            }
            Thread.sleep(1000);
        }
    }
}
